Developer Documentation

QuickTime 4 API Documentation

Wired Movies and Sprites

| Previous | Chapter Contents | Chapter Top | Next |

Adding a Series of Actions to the Penguins

The following code fragment in Listing 3-18 shows how you can add a key frame with four buttons, enabling our penguins to move through a series of actions.

Listing 18 Adding a key frame with four buttons, enabling a series of actions for our two penguins

// add actions to the six sprites
    // add go to beginning button
    myErr = QTCopyAtom(myBeginButton, kParentAtomIsContainer,
                        &myBeginActionButton);
    if (myErr != noErr)
        goto bail;

    AddSpriteSetImageIndexAction(myBeginActionButton,
                    kParentAtomIsContainer, kQTEventMouseClick, 0, NULL,
                    0, 0, NULL, kGoToBeginningButtonDownIndex, NULL);
    AddSpriteSetImageIndexAction(myBeginActionButton,
                    kParentAtomIsContainer, kQTEventMouseClickEnd, 0,
                    NULL, 0, 0, NULL, kGoToBeginningButtonUpIndex, NULL);
    AddSpriteToSample(mySample, myPrevActionButton, kGoToPrevSpriteID);
                        NULL);
    AddSpriteToSample(mySample, myNextActionButton, kGoToNextSpriteID);
    QTDisposeAtomContainer(myNextActionButton);
. . .
    // add go to end button
    myErr = QTCopyAtom(myEndButton, kParentAtomIsContainer,
                        &myEndActionButton);
    if (myErr != noErr)
        goto bail;
        kParentAtomIsContainer, kQTEventMouseExit, 0, NULL, 0, 0, NULL,
            false,
. . .

    // add penguin one
    myErr = QTCopyAtom(myPenguinOne, kParentAtomIsContainer,
                        &myPenguinOneAction);
    if (myErr != noErr)

    AddSpriteSetVisibleAction(myBeginActionButton, goto bail;

    // show the buttons on mouse enter and hide them on mouse exit
    AddSpriteSetVisibleAction(myPenguinOneAction, kParentAtomIsContainer,
                                kQTEventMouseEnter, 0, NULL, 0,
                                kTargetSpriteID, (void
                                *)kGoToBeginningSpriteID, true, NULL);
    AddSpriteSetVisibleAction(myPenguinOneAction, kParentAtomIsContainer,
                                kQTEventMouseExit, 0, NULL, 0,
                                kTargetSpriteID, (void
                                *)kGoToBeginningSpriteID, false, NULL);
. . .
    // add penguin two
    myErr = QTCopyAtom(myPenguinTwo, kParentAtomIsContainer,
                        &myPenguinTwoAction);
    if (myErr != noErr)
        goto bail;

    // blink when clicked on
    AddSpriteSetImageIndexAction(myPenguinTwoAction,
                                kParentAtomIsContainer,
                                kQTEventMouseClick, 0, NULL, 0, 0, NULL,
                                kPenguinClosedIndex, NULL);
. . .
    // add go to next button
    myErr = QTCopyAtom(myNextButton, kParentAtomIsContainer,
                        &myNextActionButton);
    if (myErr != noErr)
        goto bail;


© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |